package com.metis.document.parse.dialog.pipeline.impl;

import java.util.regex.Pattern;

import com.metis.document.parse.dialog.pipeline.TextFilter;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;

/**
 * 表格题注过滤器
 */
@Component
@Slf4j
public class TableCaptionFilter implements TextFilter {
    private static final Pattern blackListPattern = Pattern.compile("^(?:表(?:格)?\\d+)");
    @Override
    public boolean needToFilter(@NotNull String input) {
        if (blackListPattern.matcher(input.replaceAll("[\\s\\p{Zs}]","")).find()) {
            log.info("匹配到表格题注，{}", input);
            return true;
        }
        return false;
    }
}
